package com.ruoyi.mq;

import com.alibaba.fastjson.JSON;
import com.ruoyi.domain.Tenement;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RocketMQMessageListener(
        consumerGroup="overRemind-Consummer",
        topic="overRemind-topic",
        selectorExpression="overRemind-tag"
)
@Slf4j
public class OverRemingConsummer implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt messageExt) {
        byte[] body = messageExt.getBody();
        List<Tenement> tenements = JSON.parseArray(JSON.toJSONString(body), Tenement.class);
        tenements.forEach(t->{
            log.info("距离核酸结束还有1小时，请尽快参加核酸");
        });
    }
}
